﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Campus.Main.Basic.InsertValues;
using cpmntctrl;
using dbcntn;

namespace Campus.Main.Basic.Settings
{
    public partial class OrtalamForm : DefaultForm
    {
        public OrtalamForm()
        {
            InitializeComponent();
            aToDb=new ConnectionToDb(Helper.ConnectionString);
        }
        public override void Initialize()
        {
            aToDb.AddItemDBGridView(dataGridView1,Query.Puanortalama);
            ControlComponent.UnVisibleCells(dataGridView1,0);
            textBox1.Clear();
            textBox2.Clear();
            textBox3.Clear();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length > 0 && textBox2.Text.Length > 0 && textBox3.Text.Length > 0)
            {
                aToDb.InsertIntoTableOrtalam(textBox1.Text, textBox2.Text, textBox3.Text);
                Initialize();
            }
            else
            {
                MessageBox.Show("Талааларды толтургула!!!");
            }
        }

        private void OrtalamForm_Load(object sender, EventArgs e)
        {
            Initialize();
        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            List<string> data=new List<string>();
            ControlComponent.AddToList(data,dataGridView1,e,0,1,2,3);
            Ortalama f=new Ortalama(data);
            f.FormClosed += Bind;
            f.ShowDialog();

        }
    }
}
